/**
 * api
 * @type {string}
 */
var host = 'http://vfs.wefi.com.cn';

var config = {
    wx_info: 'http://api.wefi.com.cn/apiv2/?r=wx/GetWxSnInfo&open_id=%s',
    vfs_playlist: host + '/vfs/servlet/AppReqServlet?data={"opcode":"100001","pagecount":"20","token":"00000001d2f3bd4314e2554f2e76722e33cff6e6c758c366e09862185dd98f2e4c05beab","pagenum":"1","category":"500"}',
    vfs_video: host + '/vfs/servlet/WxbReqServlet?data={"token":"000000011a22eb2198c5bbcc796dbd66f74ef2f2e01677896595b9d53a840fa05d4baeb4","playlistid":"%s","opcode":"200005"}',
    vfs_videolist: host + '/vfs/servlet/AppReqServlet?data={"opcode":"100002","pagecount":"20","token":"000000011a22eb2198c5bbcc796dbd66f74ef2f2e01677896595b9d53a840fa05d4baeb4","playlistid":%s}',
    all_download_status: 'http://%s:%s/index.php/video/video/all_download_status?pagenum=1&pagecount=10&method=wxb&sponsor=1&token=%s',
    active_task_status: 'http://%s:%s/index.php/video/video/active_task_status?method=wxb&sponsor=1&token=%s',
    download_unpause: 'http://%s:%s/index.php/video/video/download_unpause?videos=%s&method=wxb&sponsor=1&token=%s',
    play_list: 'http://%s:%s/index.php/video/video/play_list?method=wxb&sponsor=1&token=%s',
    video_list: 'http://%s:%s/index.php/video/video/video_list?playid=%s&pagenum=1&pagecount=10&method=wxb&sponsor=1&token=%s',
    play_subscribe: 'http://%s:%s/index.php/video/video/play_subscribe?playlistid=%s&method=wxb&sponsor=1&token=%s',
    video_add: 'http://%s:%s/index.php/video/video/video_add?playlistid=%s&video=[%s]&method=wxb&sponsor=1&token=%s',
}





/**
 * proxy 跨域访问服务
 * @param url
 * @param response
 */
function proxy(url, response){
    var u = 'http://api.wefi.com.cn/apiv2/?r=api/ProxyRequest';
    $.ajax({
        method: 'POST',
        url: u,
        data: 'url=' + encodeURIComponent(url),
        success: function(res){
            if(response){
                response(res)
            }
        },
        error: function(){
            console.log(err)
        },
    });
}


/**
 * setCookie 存储cookie
 * @param name
 * @param value
 */

function setCookie(name, value) {
    var Days = 30;
    var exp = new Date();
    exp.setTime(exp.getTime() + Days * 24 * 60 * 60 * 1000);
    document.cookie = name + '=' + escape(value) + ';expires=' + exp.toGMTString();
}

/**
 * getCookie 获取页面存储的cookie
 * @param name
 * @returns {null}
 */

function getCookie(name) {
    var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
    if (arr = document.cookie.match(reg))
        return unescape(arr[2]);
    else
        return null;
}


